package com.tfjybj.itoo.exam.ext.mongo;

import com.tfjybj.itoo.exam.entity.OptionEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;

/**
 * @author 商俊帅
 * @date 2022/01/07 11:44
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Option {

    /**
     * 选项顺序
     */
    @ApiModelProperty(value = "选项顺序",example = "1")
    @Column(name = "option_order")
    private Integer optionOrder;

    /**
     * 选项名：字符串格式
     */
    @ApiModelProperty(value = "选项名：字符串格式",required = true)
    @Column(name = "option_name")
    private String optionName;


    private String questionId;

    /**
     * 选项名：HTML格式
     */
    @ApiModelProperty(value = "选项名：HTML格式",required = true)
    @Column(name = "option_name_html")
    private String optionNameHtml;

    /**
     * 选项是否乱序（0 否，1 是）
     */
    @ApiModelProperty(value = "选项是否乱序（0 否，1 是）",example = "1")
    @Column(name = "is_out_of_order")
    private Integer isOutOfOrder;

    /**
     * 历史题id
     */
    @ApiModelProperty(value = "历史题id")
    @Column(name = "history_id")
    private String historyId;

    public OptionEntity toOptionEntity(OptionEntity entity){
        entity.setOptionOrder(this.getOptionOrder());
        entity.setOptionName(this.getOptionName());
        entity.setQuestionId(this.getQuestionId());
        entity.setOptionNameHtml(this.getOptionNameHtml());
        entity.setIsOutOfOrder(this.getIsOutOfOrder());
        entity.setHistoryId(this.getHistoryId());
        return entity;
    }
}
